package com.clwl.supervise.superviseapp.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum RiskLevelEnum {
    PROCESS_SP("食品销售", "spxs"),
    PROCESS_CY("餐饮服务", "cyfw");

    /**
     * 流程定义缓存，key:流程定义key ，value:枚举
     */
    private static Map<String, RiskLevelEnum> map = Arrays.stream(values())
            .collect(Collectors.toMap(RiskLevelEnum::getKey, o -> o));
    /**
     * 描述信息
     */
    private final String description;

    /**
     * 流程定义key
     */
    private final String key;

    /**
     * 判断code是否相等
     *
     * @param key
     * @return
     */
    public boolean codeEquals(String key) {
        return this.getKey().equals(key);
    }

    /**
     * 获取枚举数据
     *
     * @param procDefKey 定义Key
     */
    public static RiskLevelEnum getEnum(String procDefKey) {
        return map.get(procDefKey);
    }
}
